<!DOCTYPE html>
<html layout:decorate="~{layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">

<head>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"/>

    <title>Acceptto Registration View</title>
    <link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag"/>

    <script src="https://faye.acceptto.com/faye/faye.js" type="text/javascript"></script>
    <script src="https://dbfp.acceptto.com/bfp.js" type="text/javascript"></script>
</head>

<body>
<main class="container mt-3 mb-3" role="main">
    <div class="mdc-card p-4 m-auto w-lg-66" id="login" layout:fragment="content">
        <h3>Register Device</h3>

        <ol>
            <li>Open the app store and search for "Acceptto It's Me".</li>
            <li>Install the "Acceptto It's Me" application.</li>
            <li>Open the application and follow the instructions to access the QR Code scanner.</li>
            <li>Scan this QR Code.</li>
        </ol>

        <div class="d-flex justify-content-center">
            <a class="mr-2" href="https://itunes.apple.com/us/app/acceptto-itsme/id893534370?mt=8" target="_blank">
                <img alt="App Store" height="50"
                     src="https://s3-us-west-2.amazonaws.com/acceptto-log-and-graphics/Asset+14.png" title="App Store"
                     width="151.25">
            </a>
            <a href="https://play.google.com/store/apps/details?id=com.acceptto.mfa&amp;amp;hl=en" target="_blank">
                <img alt="Google Play"
                     height="50" src="https://s3-us-west-2.amazonaws.com/acceptto-log-and-graphics/Asset+13.png"
                     title="Google Play" width="151.25">
            </a>
        </div>

        <form id="fmAccepttoQRCode" method="POST">
            <script th:inline="javascript" type="text/javascript">
                /*<![CDATA[*/
                $(function () {
                    var invitationToken = /*[[${accepttoInvitationToken}]]*/;
                    var hashCode = /*[[${accepttoInvitationTokenQRCodeHash}]]*/;
                    var src = "https://chart.apis.google.com/chart?cht=qr&chs=250x250&chl=" + hashCode + "&chld=H|0";
                    $('#qrLoginCode').attr("src", src);
                    var faye = new Faye.Client("https://faye.acceptto.com/faye");
                    faye.subscribe("/messages/" + invitationToken,
                        function (data) {
                            setTimeout(function () {
                                $('#fmAccepttoQRCode').submit();
                            }, 2500);
                        }
                    );
                });
                /*]]>*/
            </script>

            <input name="_eventId" type="hidden" value="success"/>
            <input name="execution" th:value="${flowExecutionKey}" type="hidden"/>
        </form>
        <div class="d-flex justify-content-center flex-column align-items-center">
            <img class="autowidth my-4" id="qrLoginCode" width="250"/>
            <div class="progress" style="height: 35px;">
                <div aria-valuemax="100" aria-valuemin="0"
                     aria-valuenow="99" class="progress-bar bg-info progress-bar-striped progress-bar-animated"
                     role="progressbar" style="width: 100%">
                    <span style="font-size: larger">Waiting for device registration notification...</span>
                </div>
            </div>
        </div>
    </div>
</main>


</body>

</html>